/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    vector<int> reversePrint(ListNode* head) {
        ListNode *p=head;
        vector<int> vec;
        while(p!=NULL && p->next!=NULL){
            
            vec.push_back(p->val);
            p=p->next;

        }
        if(p!=NULL)vec.push_back(p->val);
        for(int i=0,j=vec.size()-1; i<=j;i++,j--){
            int x=0;
            x=vec[i];
            vec[i]=vec[j];
            vec[j]=x;

        }
        return vec;

    }
};
